from tkinter import *
from lxg_tkinter import Quitter

fields = '姓名', '年龄', '职业'


def fetch(entries):
    for entry in entries:
        print('输入的文本是：', entry.get())


def make_form(root, fields):
    entries = []
    for field in fields:
        row = Frame(root)
        lab = Label(row, width=5, text=field)
        # 输入框
        ent = Entry(row)
        # 一行
        row.pack(side=TOP, fill=X)
        # 标签
        lab.pack(side=LEFT)
        ent.pack(side=RIGHT, expand=YES, fill=X)
        entries.append(ent)
    return entries


if __name__ == '__main__':
    root = Tk()
    ents = make_form(root, fields)
    root.bind('<Return>', (lambda event: fetch(ents)))
    Button(root, text='提交', command=(lambda: fetch(ents))).pack(side=LEFT)
    Quitter(root).pack(side=RIGHT)
    root.mainloop()
